/**
 * 项目名称: Topic_559.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月08日08时45分59秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;


// Definition for a Node.
class Node {
public:
    int val;
    vector<Node*> children;

    Node() {}

    Node(int _val) {
        val = _val;
    }

    Node(int _val, vector<Node*> _children) {
        val = _val;
        children = _children;
    }
};


class Solution {
public:
    int cnt =0;
    void order(Node* root,int length){
        if(root){
            length++;
            for(auto x:root->children){
                order(x,length);
            }
        }
        cnt= max(cnt,length);
    }
    int maxDepth(Node* root) {
        if(!root)return cnt;
        order(root,0);
        return cnt;

    }
};
